package com.example.web.controller;

import com.example.web.service.TimeIteratorNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@RestController
@Slf4j
public class ToLocalDatetimeController {

    @Autowired
    private List<TimeIteratorNode> timeIteratorNodes;

    @RequestMapping("/getLocalDateTime")
    public ResponseEntity getLocalDateTime(String timeStr) {
        for (TimeIteratorNode timeIteratorNode : timeIteratorNodes) {
            boolean condition = timeIteratorNode.condition(timeStr);
            if (condition) {
                LocalDateTime time = timeIteratorNode.parse(timeStr);
                log.info("time:{}",time);
            }
        }
        return ResponseEntity.ok().build();
    }

}
